Return type | Name and parameters |
---|---|
double[]
|
column(int col)
Select a column from a 2D array. |
double[][]
|
eachColumn(Closure closure)
Process the columns of the array. |
List
|
flatten()
Flattens a 2D array into a new collection. |
double[][]
|
transpose()
A transpose method for 2D double arrays. |
Iterator
|
transposing()
An iterator of the columns of the array. |
Select a column from a 2D array.
double[][] nums = [[1.0d, 2.0d], [10.0d, 20.0d]] assert nums.column(0) == [1.0d, 10.0d] as double[] assert nums.column(1) == [2.0d, 20.0d] as double[]
Process the columns of the array.
double[][] nums = [[1.0d, 2.0d], [10.0d, 20.0d]] nums.eachColumn { assert it[0] * 10.0d == it[1] }
closure
- the closure applied on each array columnFlattens a 2D array into a new collection. The items are copied row by row.
Example usage:
double[][] array = [[0.0f, 1.0f], [2.0f, 3.0f]] assert array.flatten() == [0.0f, 1.0f, 2.0f, 3.0f]
A transpose method for 2D double arrays.
Example usage:
double[][] doubles = [[1.0d, 10.0d], [2.0d, 20.0d]] double[][] expected = [[1.0d, 2.0d], [10.0d, 20.0d]] def result = doubles.transpose() assert result == expected assert doubles.class.componentType == result.class.componentType
An iterator of the columns of the array.
double[][] nums = [[1.0d, 2.0d], [10.0d, 20.0d]] assert nums.transpose() == nums.transposing().toList()